package com.jianfeiliao.portfolio.panel.header;

import com.jianfeiliao.portfolio.ContentManager;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;

public class NavigationPanel extends Panel {

    private static final long serialVersionUID = 1L;

    public NavigationPanel(String id) {
        super(id);
        
        ListView<?> listView = new ListView<NavigationItem>("navigationItem", ContentManager.getNavigationItems()) {
            private static final long serialVersionUID = 1L;

            @Override
            protected void populateItem(ListItem<NavigationItem> item) {
                NavigationItem navItem = item.getModelObject();
                BookmarkablePageLink<?> link = 
                        new BookmarkablePageLink<Void>("destination", navItem.getDestination());
                link.add(new Label("caption", navItem.getCaption()));
                item.add(link);
            }
        };
        add(listView);
    }
    
}
